package com.haiwen.com;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 韩要雷
 */
@WebServlet("/request2")
public class HttpServleRequest2 extends HttpServlet {

    /**
     *
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //1.获取请求参数--通过参数名获取的 getParameter("参数名") 返回一个字符串
        String name = req.getParameter("name");
        String pwd = req.getParameter("pwd");
        System.out.println("姓名："+name);
        System.out.println("密码："+pwd);

        //2.获取参数名的请求的所有参数  getParameterValues()
        String[] hobbies = req.getParameterValues("hobby");
        System.out.println(hobbies[1]);
    }
}
